package com.adee.nowcoder.huawei;

import com.adee.util.Util;

import java.util.Scanner;

public class T075 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s1 = in.nextLine();
            String s2 = in.nextLine();
            int len1 = s1.length();
            int len2 = s2.length();
            // dp[i][j]表示以s1[i]和s2[j]结尾的两个字符串的最长公共子串的长度
            // dp[i][j] =
            // 若 s1[i]==s2[j]，dp[i][j] = dp[i-1][j-1] + 1;
            // 若 s1[i]!=s2[j]，dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);
            // 初始化 dp[0][] =
            // dp[][0] =
            int[][] dp = new int[len1][len2];
            for(int i = 0; i < len1; i++) {
                if(s1.charAt(i) == s2.charAt(0)) {
                    dp[i][0] = 1;
                } else {
                    dp[i][0] = 0;
                }
            }
            for(int j = 0; j < len2; j++) {
                if(s1.charAt(0) == s2.charAt(j)) {
                    dp[0][j] = 1;
                } else {
                    dp[0][j] = 0;
                }
            }


            for(int i = 1; i < len1; i++) {
                for(int j = 1; j < len2; j++) {
                    if(s1.charAt(i) == s2.charAt(j)) {
                        dp[i][j] = dp[i-1][j-1] + 1;
                    } else {
                        dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);
                    }

                }
            }

            Util.print(dp);

            int max = 0;
            for(int i = 0; i < len1; i++) {
                for(int j = 0; j < len2; j++) {
                    if(dp[i][j] > max) {
                        max = dp[i][j];
                    }
                }
            }
            System.out.println(max);

        }
    }
}
